# vim:ts=4:sw=4:noet:
""" Miscellaneous WX support code """

import wx
from c.base.platform import Platform
import os.path
import cStringIO

def getProperPath(fn):
	if os.path.exists(fn):
		return fn
	elif os.path.exists(os.path.split(fn)[-1]):
		return os.path.split(fn)[-1]
	else:
		raise Exception("File not found: %s" % fn)

def loadWxImage(fn):
	data = file(getProperPath(Platform.getDataFilePath(fn)),"rb").read()
	im = wx.ImageFromStream(cStringIO.StringIO(data))
	return wx.BitmapFromImage(im)

def loadWxImagePlain(fn):
	data = file(getProperPath(Platform.getDataFilePath(fn)),"rb").read()
	return wx.ImageFromStream(cStringIO.StringIO(data))
